﻿// <copyright file="TestDataCollector.cs" company="Microsoft Corporation">
// Copyright (c) 2009 Microsoft Corporation All Rights Reserved
// </copyright>
// <author>Michael S. Scherotter</author>
// <email>mischero@microsoft.com</email>
// <date>2009-10-16</date>
// <summary>Test the DataCollector</summary>

namespace Test
{
    using System;
    using System.ComponentModel.Composition;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Microsoft.WebAnalytics;
    using Microsoft.WebAnalytics.Contracts;

    /// <summary>
    /// Test the <see cref="Microsoft.WebAnalytics.DataCollector"/> class
    /// </summary>
    [TestClass]
    public class TestDataCollector
    {
        /// <summary>
        /// Initializes a new instance of the TestDataCollector class.
        /// </summary>
        public TestDataCollector()
        {
            CompositionInitializer.SatisfyImports(this);
        }

        /// <summary>
        /// Gets or sets the data collector
        /// </summary>
        [Import]
        public IDataCollector DataCollector { get; set; }

        /// <summary>
        /// Test <see cref="Microsoft.WebAnalytics.AnalyticsEvent"/> serialization
        /// </summary>
        [TestMethod]
        public void TestEventSerialization()
        {
            var logEvent = new AnalyticsEvent()
            {
                MediaSource = new Uri("http://www.charette.com/media"),
                MediaStreamType = System.Windows.Media.MediaStreamType.Video,
                MediaTimeCode = new TimeSpan(1, 23, 1, 23),
                Name = "Test",
                ObjectName = "TestObject"
            };

            this.DataCollector.Log(logEvent);
        }
    }
}
